package usaco.c2009.march.bronze;

import java.util.Arrays;
import java.util.Scanner;

/*
 * p3206
 * USACO 2009 March - Bronze
 * Hint: Simple dynamic programming
 */

public class p3206 {

	static int N, C;
	static int[][] m;
	static int[] val;

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		N = scanner.nextInt();
		C = scanner.nextInt();
		m = new int[C+1][N+1];
		val = new int[C+1];
		for (int i=1;i<=C;++i) {
			val[i] = scanner.nextInt();
		}
		Arrays.sort(val, 1, val.length);
		
		for (int i=1;i<=C;++i) {
			m[i][0] = 1;
		}
		
		for (int i=1;i<=N;++i) {
			if (i % val[1] == 0) {
				m[1][i] = 1;
			}
		}
		
		for (int i=2;i<=C;++i) {
			for (int j=1;j<=N;++j) {
				if (j >= val[i]) {
					m[i][j] = m[i][j-val[i]] + m[i-1][j];
				}
				else {
					m[i][j] = m[i-1][j];
				}
			}
		}
		System.out.println(m[C][N]);
		
	}

}
